//
//  StoreCategorySubSegViewController.m
//  BaseProject
//
//  Created by 王洋 on 2020/8/6.
//  Copyright © 2020 王洋. All rights reserved.
//
#import "ServiceCatSubSegNaviView.h"
#import "StoreCategorySubListViewController.h"

#import "StoreCategorySubSegViewController.h"

@interface StoreCategorySubSegViewController ()
<XLPageViewControllerDelegate,
XLPageViewControllerDataSrouce>

@property (nonatomic, strong) XLPageViewController *pageViewController;

@property (nonatomic, strong) ServiceCatSubSegNaviView *naviView;

@end

@implementation StoreCategorySubSegViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self initView];
}

- (void)goBack {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)initView {
    
    self.title = @"结婚用品";
    self.navigationController.navigationBarHidden = YES;
    #if RT_INTERACTIVE_PUSH
        self.rt_navigationController.rt_enableInteractivePush = YES;
    #endif
    
    [self.view addSubview:self.naviView];
    
    [self.naviView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(kStatusBarHeight);
        make.height.mas_equalTo(NavBar_Height);
    }];
    
    self.pageViewController = [[XLPageViewController alloc] initWithConfig:self.config];
//    self.pageViewController.view.frame = self.view.bounds;
    self.pageViewController.delegate = self;
    self.pageViewController.dataSource = self;
    [self addChildViewController:self.pageViewController];
    [self.view addSubview:self.pageViewController.view];
    
    [self.pageViewController.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(self.naviView.mas_bottom);
        make.bottom.mas_equalTo(0);
    }];
    
}


#pragma mark -
#pragma mark TableViewDelegate&DataSource
- (UIViewController *)pageViewController:(XLPageViewController *)pageViewController viewControllerForIndex:(NSInteger)index {
    StoreCategorySubListViewController *vc = [[StoreCategorySubListViewController alloc] init];
    return vc;
}

- (NSString *)pageViewController:(XLPageViewController *)pageViewController titleForIndex:(NSInteger)index {
    return self.titles[index];
}

- (NSInteger)pageViewControllerNumberOfPage {
    return self.titles.count;
}

- (void)pageViewController:(XLPageViewController *)pageViewController didSelectedAtIndex:(NSInteger)index {
    NSLog(@"切换到了：%@",self.titles[index]);
}

- (ServiceCatSubSegNaviView *)naviView {
    if (!_naviView) {
        _naviView = [[NSBundle mainBundle] loadNibNamed:@"ServiceCatSubSegNaviView"owner:nil options:nil].firstObject;
        [_naviView.backBtn addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
    }
    return _naviView;
}

@end
